<template>
  <div class="index">
  	<div class="sreePublic">
  		<div id="" style="text-align: center;">
  			<em class="iconfont" @click="vfun_back">&#xe61f;</em>
  		</div>
		修改手机号
  	</div>
  	<div>
  		<div class="delivery">
  			<ul>
  				<li>
  					<span>新手机号：</span>
  					<input v-model="operatorPhone" placeholder="输入新手机号"/>
  				</li>
  				<li>
  					<span>验证码：</span>
  					<input v-model="rendCode" placeholder="请输入验证码"  @keyup="vfun_passnum" />
  					<span class="spanphone" @click="vfun_huoqu" :class="{active:vue_phone_verifyBtn}">{{vue_ver}}</span>
  				</li>
  				
  			</ul>
  		</div>

	     <div class="footer">
	    	<a @click="addDelivery" :class="{activeBtn:vue_passbtn}">保存</a>
	    </div>
	    
	</div>
  </div>
</template>

<script>
	import * as address from '../../assets/data/address';
	import { MessageBox } from 'mint-ui';
	import { Toast } from 'mint-ui';  //引入弹框
export default {
  name: 'addDelivery',
  data () {
    return {
    		vue_passbtn:true,
    	  vue_ver:'获取验证码',
    	  vue_phone_verifyBtn:false,
    	  operatorPhone:'',
    	  rendCode:'',
    }
  },
  methods:{
  	vfun_passnum(){
  		if (this.operatorPhone!='' && this.rendCode!='') {
  			this.vue_passbtn=false;
  		}else{
  			this.vue_passbtn=true;
  		}
  		
  	},
  	vfun_huoqu(){
  		if (this.operatorPhone !='') {
  			let str=this.Public.rules.phone;
			if(str.test(this.operatorPhone) != true){
				Toast({
				  message: '手机号格式错误',
				  iconClass: 'fontSize iconfont icon-shibai'
				});
//						MessageBox('提示', '请填写正确的手机号');
				return false;
			} 
  		}else{
  			Toast({
				  message: '请填写新手机号',
				  iconClass: 'fontSize iconfont icon-shibai'
				});
  			return false;
  		}
  		let num = 60;
			this.vue_phone_countDown = setInterval(()=>{
				this.vue_ver = num+"后重新获取";
				this.vue_phone_verifyBtn=true;
				num--;
				if(num<=-1){
					clearInterval(this.vue_phone_countDown);
					this.vue_phone_verifyBtn=false;
					this.vue_ver = "重新获取";
				}
			},1000);
		this.axios({
			method: 'PATCH',
			url: "/v3/member/operators/"+this.phone+"/sendPhoneVerifyCode",
			data:{
			}
			}).then((res) => {

			}).catch((err)=>{
				Toast({
				  message: err.response.data,
				  iconClass: 'fontSize iconfont icon-shibai'
				});
	  	});
		
  	},
	addDelivery(){
		if (this.rendCode=='') {
			Toast({
				  message: '请填写验证码',
				  iconClass: 'fontSize iconfont icon-shibai'
				});
			return false;
		}
		if (this.operatorPayPassword=='') {
			Toast({
			  message: '请填写支付密码',
			  iconClass: 'fontSize iconfont icon-shibai'
			});
			return false;
		}
//		this.axios({
//			method: 'PUT',
//			url: "/v3/member/operators/"+this.rendCode+"/"+this.md5(this.operatorPayPassword).toUpperCase()+"/settlePayPassword",
//			data:{
//			}
//			}).then((res) => {
//				Toast({
//				  message: '设置成功',
//				  iconClass: 'fontSize iconfont icon-chenggong'
//				});
//			}).catch((err)=>{
//				Toast({
//				  message: err.response.data,
//				  iconClass: 'fontSize iconfont icon-shibai'
//				});
//	  	});
		

		
	},
  	vfun_back(){
  		history.back();
  	},
  	
  },
  watch: {
      
  },
    created(){
    },
  mounted(){
  	
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
*{
	transition: 0.2s;
}
h1, h2 {
  font-weight: normal;
}

ul {
  list-style-type: none;
  padding: 0;
}
.index{
	box-sizing: border-box;
	margin-bottom: 1.5rem;
}

.delivery{
	margin-top: 1.2rem;
}
.delivery li{
	border-bottom: 1px solid #e7e7e7;
	box-sizing: border-box;
	background: #fff;
	line-height: 1.5rem;
	height: 1.5rem;
	width: 90%;
	margin: 0 auto;
	position: relative;
	font-size: 16px;
}

.delivery input{
	border: 0;
	height: 1rem;
}
.delivery .spanphone{
	display: block;
	position: absolute;
	height: 1rem;
	line-height:1rem;
	right: 5%;
	top: 0.25rem;
	font-size: 14px;
	border-left:1px solid #e7e7e7;
	padding-left: 0.2rem;
	
}
.pass{
	position: absolute;
	padding: 0.15rem 0.2rem;
	right: 6%;
	top: 19%;
	color: #b0b0b0;
}
.footer{
	background: #fff;
	width: 100%;
}
.footer a{
	display: block;
	width: 90%;
	margin: 0 auto;
	margin-top: 0.5rem;
	color: #fff;
	text-align: center;
	height: 1rem;
	background: #D50B0A;
	line-height: 1rem;
	border-radius:4px ;
}
.delivery .iconfont{
	float: right;
	color: #ccc;
	font-size: 14px;
}
.deliverytab{
	width: 10rem;
	height: 9rem;
}
.delivery-th{
	margin-top: 0.4rem;color: #D50B0A;
}
.delivery-th span:first-child{
	float: left;
	margin-left: 5%;
}
.delivery-th span:last-child{
	float: right;
	margin-right: 5%;
}
.active{
	pointer-events: none;
}
.activeBtn{
		background: #EEEEEE!important;
		color: #d4d4d4!important;
		pointer-events: none;
	}
</style>
